import 'package:boss/models/material.dart' as material;
import 'package:boss/models/store_menu.dart';

import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

import 'provider/material_setting_provider.dart';
import 'widget/material_browser.dart';

@RouterConfig(MaterialSettingPage.pageName)
class MaterialSettingPage extends StatefulWidget {
  static const pageName = '/materialSetting';

  @Autowired()
  final StoreMenu menu;

  @Autowired()
  final List<material.Material> materials;

  @Autowired()
  final int meterialType;

  const MaterialSettingPage({
    this.menu,
    this.materials,
    this.meterialType,
  });

  @override
  _MaterialSettingPageState createState() => _MaterialSettingPageState('添加菜品口味');
}

class _MaterialSettingPageState extends BaseState<MaterialSettingPage> {
  _MaterialSettingPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (context) => MaterialSettingProvider(
            menu: widget.menu,
            commodityMaterials: widget.materials,
            meterialType: widget.meterialType,
          ),
        )
      ],
      child: Scaffold(
        appBar: CenterTitleAppBar(
          title: '加料配菜',
        ),
        body: MaterialBrowser(),
      ),
    );
  }
}
